package it.gma.torero.operator;

import it.gma.torero.operand.Operand;


/**
 * In logic, <a href="http://en.wikipedia.org/wiki/Logical_negation">negation</a>, also called logical complement, is an operation that
 * essentially takes a proposition p to another proposition "not p", written ¬p,
 * which is interpreted intuitively as being true when p is false and false when
 * p is true. Negation is thus a unary (single-argument) logical connective. It
 * may be applied as an operation on propositions, truth values, or semantic
 * values more generally. In classical logic, negation is normally identified
 * with the truth function that takes truth to falsity and vice versa. In
 * intuitionistic logic, according to the Brouwer–Heyting–Kolmogorov
 * interpretation, the negation of a proposition p is the proposition whose
 * proofs are the refutations of p.
 * 
 * 
 * 
 * @author giordano
 * 
 */
public class NotOperator extends AbstractBooleanOperator {

	

	public NotOperator(Operand operand1) {
		super(operand1);

	}

	public boolean evaluate() {
		
		if (operand1.getValue() == null ) {
			throw new RuntimeException("Operand value cannot be null");
		}
		
		return (!(Boolean)operand1.getValue());
	}

	@Override
	public String toString() {
		return "!(" + operand1 + ")";
	}

}
